home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Development Tools & Languages / Dylan Related / Thomas / MacGambit⁄Thomas / MacGambit⁄Thomas Sources / Reference Notes / README.toolbox < prev    next >
Encoding:
Text File  |  1995-03-15  |  13.1 KB  |  316 lines  |  [TEXT/ttxt]

  1. This document here because the documentation for MacGambit toolbox calls was not always complete, in the sense that the arguments required by some functions were not always obvious.  The toolbox calls are VERY unforgiving - supplying a bogus value (say, #f, instead of a window id to mac#setport) is a very quick way to exit your application.  Good example code is provided for some of the toolbox calls in the reference directory and in the samples directory.  Here is some additional documentation:
  2.  
  3. Terms:
  4.     window id - an integer value returned by a call to mac#newwindow, mac#frontwindow, etc. which is the window id or pointer to the window entity
  5.     mac#point - a structure consisting of a vertical screen coordinate v and a horizontal screen coordinate h
  6.     mac#rect - a structure consisting of top, bottom, left, and right screen coordinates
  7.     port - usually a window id returned from (i.e.) mac#newwindow
  8.  
  9. Toolbox Functions:
  10. (Note:  if functions are not useful, or usage has not been determined, the function name is not in special font)
  11.  
  12. Windows:
  13.  
  14. (mac#newwindow bounds title visible procid behind goaway)
  15.     bounds - a mac#rect structure (mac#rect top bottom left right)
  16.     title - a string for the window title
  17.     visible - #t or #f, controlling whether the window is shown
  18.     procid - actually the window type as given in Macintosh Toolbox essentials, Ch 4 Window Manager
  19.             0 - movable,sizable, window, no zoom box
  20.             1 - alert box or modal dialog box
  21.             2 - plain box
  22.             3 - plain box with shadow
  23.             4 - movable window, no size box or zoom box
  24.             5 - movable modal dialog box
  25.             8 - standard document window
  26.             12 - zoomable, resizable window
  27.             16 - rounded-corner window
  28.     behind - controls what window(s) the new window is behind
  29.             -1 - none (put in front)
  30.             0 - all (put in back)
  31.             winid - where winid is window id of the window that the new window is to be put behind
  32.     goaway - #t or #f, controls whether the window has a goaway box
  33.  
  34. It should be noted that merely providing a goaway box or making the window movable, zoomable or resizable will not automatically confer these capabilities on the window.  For hints about what code to use to do this, see the examples in ???
  35.  
  36. (mac#getnewwindow windowid behind)
  37.     windowid - a resource ID of new window (must have been added to the MacGambit world using ResEdit
  38.     behind - -1, 0, or winid as in newwindow, above
  39.  
  40. (mac#disposewindow w) - kills the window pointed to by w (note:  trying to do anything with w after this call will kill you dead)
  41.     w - window id
  42.  
  43. (mac#selectwindow w) - selects the window (brings it to front)
  44.     w - window id
  45.  
  46. (mac#hidewindow w) - hides the window (makes it invisible)
  47.     w - window id
  48.  
  49. (mac#showwindow w) - makes the window visible but does not otherwise affect it:  the window may be underneath other windows and will not accept input until selected
  50.     w - window id
  51.  
  52. (mac#frontwindow) - returns the window id of frontmost window
  53.  
  54. (mac#findwindow pt w-cell) - puts the window id of the frontmost window that contains the point pt in the car of w-cell
  55.     pt - a mac#point structure (see mac#point call, below)
  56.     w-cell - a list of at least two members, the car of which is the destination for the window id
  57.  
  58. (mac#trackgoaway w pt) - used to return whether the mouse was clicked and released in the goaway    box of the window with window id w
  59.     w - window id of window where goaway box was clicked
  60.     pt - a mac#point structure
  61.  
  62. (mac#dragwindow w pt r) - allows a window to be dragged by the title bar within a rectangle r when clicked on the title bar at point pt
  63.     w - window id
  64.     pt - a mac#point structure
  65.     r - a mac#rect structure
  66.  
  67. (mac#invalrect port r) - invalidates a rectangular region r in a port
  68.     port - window id
  69.     r - mac#rect structure
  70.  
  71. (mac#beginupdate w) - begins update process
  72.     w - window id
  73.  
  74. (mac#endupdate w) - ends update process
  75.     w - window id
  76.  
  77. Quickdraw 
  78.  
  79. (mac#point v h) - creates a pt structure at v, h
  80.     v - vertical window coordinate
  81.     h - horizontal window coordinate
  82.  
  83. (mac#point-v r) - gets vertical coordinate from r
  84.     r - a mac#point structure
  85. (mac#point-h r) - gets horiz coord from r
  86.     r - a mac#point structure
  87. (mac#point-v-set! r x) - sets horiz coord of r
  88.     r - a mac#point structure
  89.     x - a screen coordinate (integer)
  90. (mac#point-h-set! r x) - sets vertical coord of r
  91.     r - a mac#point structure
  92.     x - a screen coordinate (integer)
  93.  
  94. (mac#rect top left bottom right) - creates a mac#rect structure
  95. (mac#rect-top r) - returns the top screen coord of r
  96.     r - a mac#rect structure
  97. (mac#rect-left r) - returns the left screen coord of r
  98.     r - a mac#rect structure
  99. (mac#rect-bottom r) - returns the bottom screen coord of r
  100.     r - a mac#rect structure
  101. (mac#rect-right r) - returns the right screen coord of r
  102.     r - a mac#rect structure
  103. (mac#rect-top-set! r x) - sets the top screen coord of r to x
  104.     r - a mac#rect structure
  105.     x - a screen  coordinate (integer) 
  106. (mac#rect-left-set! r x) - sets the top screen coord of r to x
  107.     r - a mac#rect structure
  108.     x - a screen  coordinate (integer) 
  109. (mac#rect-bottom-set! r x) - sets the top screen coord of r to x
  110.     r - a mac#rect structure
  111.     x - a screen  coordinate (integer) 
  112. (mac#rect-right-set! r x) - sets the top screen coord of r to x
  113.     r - a mac#rect structure
  114.     x - a screen  coordinate (integer)
  115.  
  116. (mac#openport port) - not really needed
  117. (mac#initport port) - ditto 
  118. (mac#closeport port) - ditto
  119. (mac#setport port) - sets the output port for Quickdraw to the specified port
  120.     port - a graphics port (typically a window id)
  121. (mac#getport) - returns the currently active QD port
  122. (mac#setorigin port h v)
  123. (mac#backpat port pat) - sets the background pattern of the graphics port to the supplied pattern
  124.     port - a graphics port (typically a window id)
  125.     pat - a string of length of length 4 works here - the characters determine the pattern
  126. (mac#hidecursor) - make cursor invisible
  127. (mac#showcursor) - make cursor visible
  128. (mac#pensize port width height) - sets the pen width and height
  129.     port - a graphics port (typically a window id)
  130.     width - desired pen width in pixels (integer)
  131.     height - desired pen height in pixels (integer)
  132. (mac#penmode port mode) - sets the pen mode which controls how a graphic operation (say, drawing a line) affects the pixels being drawn.
  133.     port - a graphics port (typically a window id)
  134.     mode - an integer:
  135.         8 - Copy (black->foreground, white->background)
  136.         9 - Or (black->invert, white->white)
  137.         10 - Xor (use this mode to toggle a graphic)
  138.         11 - Bic (black->background, white->white)
  139.         12 - notCopy (black->background, white->foreground)
  140.         13 - notOr (black->black, white->foreground)
  141.         14 - notXor (black->black, white->invert)
  142.         15 - notBic (black->black, white->background)
  143.         50 - Highlight
  144. (mac#penpat port pat) - sets the foreground pen pattern
  145.     port - a graphics port (typically a window id)
  146.     pat - a pattern (string of length 4) of bits
  147. (mac#pennormal port) - returns the pen to default settings
  148.     port - a graphics port (typically a window id)
  149. (mac#moveto port h v) - moves the graphics pen to h,v
  150.     port - a graphics port (typically a window id)
  151.     h - a horizontal window coordinate (integer)
  152.     v - a vertical window coordinate (integer)
  153. (mac#move port dh dv) - moves the graphics pen by dh,dv
  154.     port - a graphics port (typically a window id)
  155.     dh - a horizontal displacement (integer)
  156.     dv - a vertical displacement (integer)
  157. (mac#lineto port h v) - draws a line from current pt to h,v
  158.     port - a graphics port (typically a window id)
  159.     h - a horizontal window coordinate (integer)
  160.     v - a vertical window coordinate (integer)
  161. (mac#line port dh dv) - draws a line from current pt along dh,dv
  162.     port - a graphics port (typically a window id)
  163.     dh - a horizontal displacement (integer)
  164.     dv - a vertical displacement (integer)
  165. (mac#textfont port font) - sets the port text to specified font
  166.     port - a graphics port (typically a window id)
  167.     font - a string, such as "chicago"
  168. (mac#textmode port mode) - sets the port text to mode 
  169.     port - a graphics port (typically a window id)
  170.     mode - (see mac#penmode, above)
  171. (mac#textsize port size) - set port text size
  172.     port - a graphics port (typically a window id)
  173.     mode - (see mac#penmode, above)
  174. (mac#spaceextra port extra)
  175. (mac#drawchar port ch) - draws a character ch on the port at the current graphics pen location
  176.     port - a graphics port (typically a window id)
  177.     ch - a character
  178. (mac#drawstring port s) - draws a string s on the port at the current graphics pen location
  179.     port - a graphics port (typically a window id)
  180.     s - a string
  181. (mac#drawtext port textbuf firstbyte bytecount)
  182.     port - a graphics port (typically a window id)
  183.     textbuf - a string
  184. (mac#charwidth port ch) - returns the width of ch in pixels in the current font on the port
  185.     port - a graphics port (typically a window id)
  186.     ch - a character
  187. (mac#stringwidth port s) - returns the width of s in pixels
  188.     port - a graphics port (typically a window id)
  189.     s - a string
  190. (mac#textwidth port textbuf firstbyte bytecount)
  191. (mac#localtoglobal port pt) - convert window coords in window port of pt to screen coords
  192.     port - a graphics port (typically a window id)
  193.     pt - a mac#point
  194. (mac#globaltolocal port pt) - convert screen coords of pt to window coords in the window port
  195.     port - a graphics port (typically a window id)
  196.     pt - a mac#point
  197. (mac#framerect port r) - draw a rectangle (outline)
  198.     port - a graphics port (typically a window id)
  199.     r - a mac#rect
  200. (mac#paintrect port r) - draw a rectangle (filled)
  201.     port - a graphics port (typically a window id)
  202.     r - a mac#rect
  203. (mac#eraserect port r) - erase a rectangle
  204.     port - a graphics port (typically a window id)
  205.     r - a mac#rect
  206. (mac#invertrect port r) - invert the pixels of a rectangle
  207.     port - a graphics port (typically a window id)
  208.     r - a mac#rect
  209. (mac#fillrect port r pat) - fill a rectangle with a pattern
  210.     port - a graphics port (typically a window id)
  211.     r - a mac#rect
  212.     pat - a pattern (string of length 4)
  213. (mac#frameroundrect port r ovwd ovht)
  214.     port - a graphics port (typically a window id)
  215.     r - a mac#rect
  216.     ovwd - edge-rounding oval width
  217.     ovht - edge-rounding oval height
  218. (mac#paintroundrect port r ovwd ovht)
  219.     port - a graphics port (typically a window id)
  220.     r - a mac#rect
  221.     ovwd - edge-rounding oval width
  222.     ovht - edge-rounding oval height
  223. (mac#eraseroundrect port r ovwd ovht)
  224.     port - a graphics port (typically a window id)
  225.     r - a mac#rect
  226.     ovwd - edge-rounding oval width
  227.     ovht - edge-rounding oval height
  228. (mac#invertroundrect port r ovwd ovht)
  229.     port - a graphics port (typically a window id)
  230.     r - a mac#rect
  231.     ovwd - edge-rounding oval width
  232.     ovht - edge-rounding oval height
  233. (mac#fillroundrect port r ovwd ovht pat)
  234.     port - a graphics port (typically a window id)
  235.     r - a mac#rect
  236.     ovwd - edge-rounding oval width
  237.     ovht - edge-rounding oval height
  238.     pat - a pattern (string of length 4)
  239. (mac#frameoval port r)
  240.     port - a graphics port (typically a window id)
  241.     r - a mac#rect
  242. (mac#paintoval port r)
  243.     port - a graphics port (typically a window id)
  244.     r - a mac#rect
  245. (mac#eraseoval port r)
  246.     port - a graphics port (typically a window id)
  247.     r - a mac#rect
  248. (mac#invertoval port r)
  249.     port - a graphics port (typically a window id)
  250.     r - a mac#rect
  251. (mac#filloval port r)
  252.     port - a graphics port (typically a window id)
  253.     r - a mac#rect
  254. (mac#framearc port r startangle arcangle)
  255. (mac#paintarc port r startangle arcangle)
  256. (mac#erasearc port r startangle arcangle)
  257. (mac#invertarc port r startangle arcangle)
  258. (mac#fillarc port r startangle arcangle pat)
  259.  
  260. Menus   (see examples in Utilities.scm)
  261.  
  262. (mac#newmenu menuid str)
  263. (mac#getmenu resourceid)
  264. (mac#disposemenu themenu)
  265. (mac#appendmenu themenu str)
  266. (mac#addresmenu themenu thetype)
  267. (mac#insertresmenu themenu thetype)
  268. (mac#insertmenu themenu beforeid)
  269. (mac#drawmenubar)
  270. (mac#deletemenu menuid)
  271. (mac#clearmenubar)
  272. (mac#getnewmbar menubarid)
  273. (mac#setmenubar menulist)
  274. (mac#menuselect p)
  275. (mac#menukey ch)
  276. (mac#hilitemenu menuid)
  277. (mac#disableitem themenu item)
  278. (mac#enableitem themenu item)
  279. (mac#getmhandle menuid)
  280.  
  281. Events
  282.  
  283. (mac#event-what event)
  284. (mac#event-message event)
  285. (mac#event-when event)
  286. (mac#event-where event)
  287. (mac#modifiers event)
  288.  
  289. (mac#modifiers-button? modifiers)
  290. (mac#modifiers-command? modifiers)
  291. (mac#modifiers-shift? modifiers)
  292. (mac#modifiers-alphalock? modifiers)
  293. (mac#modifiers-option? modifiers)
  294.  
  295. Standard file get/put
  296.  
  297. (mac#sfgetfile [prompt] [filetype]) - pops up standard input file dialog box, and if filetype is supplied, shows only files of that type, otherwise "TEXT"; returns a filename
  298.     [prompt] - only required if filetype is to be supplied - ignored
  299.     [filetype] - (optional) four-character type ("TEXT", "PICT", etc.) - more 4-character strings may be appended for additional types, such as creator ("gamO", etc.)
  300. (mac#sfputfile [prompt] [filename]) - pops up a standard output file dialog box, with prompt above file name entry box, and filename in file entry box, if supplied
  301.     [prompt] - (optional) prompt above file box - a  string
  302.     [filename] - (optional) default filename - a string
  303.  
  304. Misc
  305.  
  306. (mac#getmouse pt) - returns the current location of the mouse in the location pt in window coords (pt must have been set to a mac#point structure before calling)
  307. (mac#button) - returns #t if mouse button has been pressed, otherwise #f
  308. (mac#tickcount) - returns an integer which is the total time the computer has been running at the time of the call, in 1/60's of a second
  309. (mac#delay duration) - delays operation for duration
  310.     duration - time in 1/60's of a second
  311. (mac#sysbeep duration) - invoke error beep for duration
  312.     duration - time in 1/60's of a second
  313. (mac#seteventmask themask)
  314.  
  315.  
  316.